package com.egao.go.service.impl;

import com.egao.common.core.damon.results.PageResult2;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.entity.User;
//import com.egao.go.mapper.DutchMapper;
import com.egao.go.entity.Dutch;
import com.egao.go.service.DutchService;
import org.springframework.stereotype.Service;
import com.egao.go.biz.DutchBiz;
import net.sf.json.JSONObject;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
//import javax.transaction.Transactional;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 群AA服务实现类
 * @author : Doman
 * @date : 2020-09-21 10:28:24
 * @version ：1.0
 */
@Service
public class DutchServiceImpl /*extends ServiceImpl<DutchMapper, Dutch> */implements DutchService {

	@Autowired
	private DutchBiz dutchBiz;

    /**
    @Override
    public PageResult<Dutch> listPage(PageParam<Dutch> page) {
        List<Dutch> records = baseMapper.listPage(page);
        return new PageResult<>(records, page.getTotal());
    }

    @Override
    public List<Dutch> listAll(Map<String, Object> page) {
        return baseMapper.listAll(page);
    } */

    @Override
    public JsonResult list(PageResult2<T> page, Dutch dutch, User loginUser)  throws Exception{
        return dutchBiz.list(page,dutch,loginUser);
    }

    @Override
    public JsonResult listExamine(PageResult2<T> page, Dutch dutch, User loginUser)  throws Exception{
        return dutchBiz.listExamine(page,dutch,loginUser);
    }

    @Override
    public JsonResult list(Dutch dutch, User loginUser) {
        return JsonResult.ok().setData(dutchBiz.list(dutch,loginUser));
    }

    @Override
    public JsonResult unExamineNums(Dutch dutch, User loginUser) {
        return JsonResult.ok().setData(dutchBiz.unExamineNums(dutch,loginUser));
    }

    @Override
    public JsonResult getById(Dutch dutch) {
        return JsonResult.ok().setData(dutchBiz.getById(dutch));
    }

    @Transactional
    @Override
    public JsonResult save(Dutch dutch, User loginUser) {
        return JsonResult.ok("添加成功").put("id",dutchBiz.save(dutch, loginUser));
    }

    @Transactional
    @Override
    public JsonResult update(Dutch dutch, User loginUser) {
        if (dutchBiz.update(dutch, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult updateState(Dutch dutch, User loginUser) {
        if (dutchBiz.updateState(dutch, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult updateExamine(Dutch dutch, User loginUser) {
        if (dutchBiz.updateExamine(dutch, loginUser)) {
            return JsonResult.ok("修改成功");
        }
        return JsonResult.error("修改失败");
    }

    @Transactional
    @Override
    public JsonResult remove(Dutch dutch, User loginUser) {
        if (dutchBiz.remove(dutch, loginUser)) {
            return JsonResult.ok("删除成功");
        }
        return JsonResult.error("删除失败");
    }

}
